package com.hongye.area.controller;

import java.util.Arrays;
import java.util.Hashtable;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.area.entity.SubwayStationEntity;
import com.hongye.area.service.SubwayStationService;
import com.zxy.common.utils.PageUtils;
import com.zxy.common.utils.R;



/**
 * 
 *
 * @author cyj
 * @email sunlightcs@gmail.com
 * @date 2022-04-22 16:19:01
 */
@RestController
@RequestMapping("area/subwaystation")
public class SubwayStationController {
    @Autowired
    private SubwayStationService subwayStationService;

    /**
     * 列表
     */
    @RequestMapping("/list/{mid}")
    public R list(@RequestParam Map<String, Object> params,@PathVariable("mid")Long mid){
        PageUtils page = subwayStationService.queryPage(params,mid);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{sid}")
    public R info(@PathVariable("sid") Long sid){
		SubwayStationEntity subwayStation = subwayStationService.getById(sid);

        return R.ok().put("subwayStation", subwayStation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save/{mid}")
    public R save(@RequestBody SubwayStationEntity subwayStation,@PathVariable("mid")Long mid){
        subwayStation.setMid(mid);
		subwayStationService.save(subwayStation);

        return R.ok("地铁站添加成功");
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SubwayStationEntity subwayStation){
		subwayStationService.updateById(subwayStation);

        return R.ok("地铁站修改成功");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] sids){
		subwayStationService.removeByIds(Arrays.asList(sids));

        return R.ok();
    }

}
